/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.iie.ac.testbak0605;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONObject;

/**
 *
 * @author xiaoliang
 */
public class testSql {

    public static String getInsertSql1() {
        List<String> list = new ArrayList<>();
        list.add("col");
        list.add("row");
        list.add("key");
        StringBuilder sql = new StringBuilder();
        sql.append("INSERT INTO ");
        sql.append("table");
        sql.append(" VALUES(");
        for (int i = 0; i < list.size(); i++) {
            sql.append("?,");
        }
        String insertSql = sql.substring(0, sql.length() - 1) + ")";
        return insertSql;
    }

    public static void main(String[] args) {
//        String content = "{\"req_id\":\"1dsasd4t5\",\"type\":1,\"in_sql\":\"select count(*) from table\",\"status\":\"ok\",\"detail\":\"detail\",\"result\":\"result\",\"task_id\":\"1234\",\"timestamp\":12345677,\"uniq_seq\":\"uniq_seq\"}";
//        content = "{\"name\":123,\"col\":{\"age\":23,\"gender\":1}}";
//        Map<String, Object> contentMsg = JSON.parseObject(content);
//        for (String colString : contentMsg.keySet()) {
//            System.out.println(colString+" : "+contentMsg.get(colString));
//        }
        Map<String, Object> channel = new HashMap<>();
        Map<String, Object> col = new HashMap<>();
        channel.put("showChannel", "微信");
        channel.put("srcChannel", "wx");
        channel.put("showTable", "微信交互");
        channel.put("srcTable", "wxjh");
        List<Map> cols = new ArrayList<>();
        Map<String, Object> col1 = new HashMap<>();
        col1.put("showCol", "获取时间");
        col1.put("srcCol", "it");
        Map<String, Object> col2 = new HashMap<>();
        col2.put("showCol", "网址");
        col2.put("srcCol", "url");
        cols.add(col1);
        cols.add(col2);
        channel.put("cols", cols);
        System.out.println(channel.toString());
        JSONObject jsonObject = JSONObject.fromObject(channel);
        System.out.println(jsonObject.toString());

        Map map1 = new HashMap();
        List<Map<String, Object>> haha = new ArrayList<>();
        for (int i = 0; i < 3; i++) {
            Map<String, Object> map = new HashMap<>();
            map.put("url" + i, i * 10);
            haha.add(map);
        }
        map1.put("urls", haha);
        JSONObject json = JSONObject.fromObject(map1);
        System.out.println(json.toString());

    }

}
